package com.mql.ganio.ui.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import com.mql.ganio.R;
import com.mql.ganio.ui.base.BaseFragmentActivity;
import com.mql.ganio.widget.PinchImageView;

/**
 * 作者：Administrator on 2017/11/8 19:17
 */
public class MyPageAdapter extends PagerAdapter {
    private BaseFragmentActivity context;
    private int imageId;
    public MyPageAdapter(BaseFragmentActivity context,int imageId){
        this.context=context;
        this.imageId=imageId;
    }
    @Override
    public int getCount() {
        return 1;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = context.getLayoutInflater().inflate(R.layout.viewpager_very_image, container, false);
        PinchImageView zoom_image_view = (PinchImageView) view.findViewById(R.id.zoom_image_view);
        ProgressBar spinner = (ProgressBar) view.findViewById(R.id.loading);
        spinner.setVisibility(View.GONE);
        if (imageId != 0) {
            zoom_image_view.setImageResource(imageId);
        }
        container.addView(view, 0);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        View view = (View) object;
        container.removeView(view);
    }
}
